<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Import as Example</title>
</head>
<body>
{# 使用from...import...as...导入宏 #}
<h1>Using from...import...as...</h1>

{% from 'forms.html' import input as input_field,textarea %}

<form action="/save2" method="post" name="form1">

<dl>
    <dt>Username</dt>
    <dd>{{ input_field('username',value=username) }}</dd>
    <dt>Password</dt>
    <dd>{{ input_field('password',type='password',value=password) }}</dd>
</dl>

<p>{{ textarea('comment',value=comment) }}</p>

    <button type="submit">Submit (Form1)</button>
</form>


{# 使用from...import...with context导入宏 #}
<h1>Using from...import...with context</h1>

{% from 'forms.html' import input with context %}
{% from 'forms.html' import textarea with context %}

<form action="/save2" method="post" name="form2">

<dl>
    <dt>Username</dt>
    <dd>{{ input('username',value=username) }}</dd>
    <dt>Password</dt>
    <dd>{{ input('password',type='password',value=password) }}</dd>
</dl>

<p>{{ textarea('comment',value=comment) }}</p>

    <button type="submit">Submit (Form2)</button>
</form>
</body>
</html>